package com.yb0os1;

import com.yb0os1.mapper.UserMapper;

import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        //我们想要实现的效果也就是类似mybatis，可以通过下面的方式进行数据库操作
        MySqlsessionFactory sqlsessionFactory = new MySqlsessionFactory();
        UserMapper userMapper = sqlsessionFactory.getMapper(UserMapper.class);
        System.out.println(userMapper.selectById(1));
        System.out.println("======================================");
        System.out.println(userMapper.selectByName("yb0os1"));
        System.out.println("======================================");
        System.out.println(userMapper.selectByIdAndName(1,"yb0os1"));
        System.out.println("======================================");
        System.out.println(userMapper.selectBatchByIds(Arrays.asList(1, 2)));
        System.out.println("======================================");
        System.out.println(userMapper.selectBatchByNames(Arrays.asList("yb0os1", "test")));
        System.out.println("======================================");
        System.out.println(userMapper.selectBatchByIdsAndNames(Arrays.asList(1, 2),Arrays.asList("yb0os1", "test")));
        System.out.println("======================================");
        User user = new User(6, "alice");
        boolean b = userMapper.insertUser(user);
        if (b){
            System.out.println(user.id+"--"+user.name+"插入成功");
        }
        System.out.println("======================================");
    }
}